package com.instalinks.android.apps.smspostservice.tasks;

import android.content.Context;
import android.os.AsyncTask;

import com.instalinks.android.apps.smspostservice.HomeActivity;
import com.instalinks.android.apps.smspostservice.helper.AppConfig;
import com.instalinks.android.lib.ApplicationNotifications;

public class UpdateConfigTask extends AsyncTask<Void, Void, Boolean> {
	private AppConfig appCfg;

	public UpdateConfigTask(Context context) {
		appCfg = new AppConfig(context);
	}

	@Override
	protected Boolean doInBackground(Void... params) {

		boolean result = appCfg.updateConfigFromHost();

		return result;
	}

	@Override
	protected void onPostExecute(Boolean result) {
		ApplicationNotifications appNotifications = appCfg
				.getExternalNotificationInstance();

		if (result)
			appNotifications.notify("Configuration Updated",
					HomeActivity.class.getName());
		else
			appNotifications.notify("Config Update Failed");
	}
}